<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\Users;
use App\Jobs\Htmlosshanndle;
use App\Services\OutputService;
use Cookie,Log,Exception;

class LoginController extends Controller
{
    public function homeLogin(Request $request)
    {
        $username = $request->phone;
        $corp_type = $request->corp_type;
        $name = $request->name;
        $users = Users::getAdminByUsername($username);
        if (empty($users)) {
            $users_id = Users::createUserByPhone($username);
            $token = encrypt($users_id);
        } else {
            $token = encrypt($users->id);
        }
        return OutputService::success("SUCCESS",["token"=>$token]);
    }
}
